package com.yang.booking.controller;

import com.yang.booking.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class StoreController {

    @Autowired
    private StoreService storeService;

    @PostMapping("/provider/store/insertStore")
    public Map<String, Object> insertStore(@RequestParam(name = "name") String name,
                                           @RequestParam(name = "address") String address,
                                           @RequestParam(name = "schedulingCycle") String schedulingCycle,
                                           @RequestParam(name = "regionId") String regionId
    ){
        return storeService.insertStore(regionId, name, address, Integer.parseInt(schedulingCycle));
    }

    @PostMapping("/provider/store/updateStoreSchedulingCycle")
    public Map<String, Object> updateStoreSchedulingCycle(@RequestParam(name = "storeId") String storeId,
                                                       @RequestParam(name = "schedulingCycle") String schedulingCycle
    ){
        return storeService.updateStoreSchedulingCycle(storeId, schedulingCycle);
    }
}
